package com.jl.book.db

import android.content.Context
import androidx.room.*
import com.jl.book.bean.Contacts
import com.jl.book.global.TABLE_FOR_CONTACT

@Dao
abstract class ContactDao {

    @Transaction
    open fun insertAll(contacts: List<Contacts>) {
        insertList(contacts)
    }

    @Transaction
    open fun deleteAll(contacts: List<Contacts>){
        deleteList(contacts)
    }

    @Query("select * from Contacts where name like '%' || :edit || '%'")
    abstract fun getFind(edit: String): List<Contacts>?

    @Query("SELECT * FROM Contacts")
    abstract fun getTest():List<Contacts>?

    @Query("DELETE from Contacts where id =:id")
    abstract fun delete(id:Int)

    @Insert
    abstract fun insert(contacts: Contacts)

    @Update
    abstract fun update(contacts: Contacts)

    @Insert
    abstract fun insertList(contacts: List<Contacts>)

    @Delete
    abstract fun deleteList(contacts: List<Contacts>)
}